<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .bColor {
      background-color: yellow;
    }
  </style>
  <script type="text/javascript">
    window.onload = function () {
      let num = 1;
    	let btn = document.createElement("button");
    	btn.innerText = "测试按钮";

    	document.body.appendChild(btn);

    	btn.onclick = function () {
    		num++;
    		if (num % 2 === 0) {
					btn.classList.add("bColor");
        } else {
    			btn.classList.remove("bColor")
        }
			}

		}
  </script>
</head>
<body>

</body>
</html>
